package com.srcptit.java.tranning.hoangdd.btvn1;

import java.util.Scanner;

public class Bai7Muc1{
	public static int thuan_nghich(int n){
		int a=n,b=0;
		while(n>0){
			b=b*10 + n%10;
			n/=10;
		}
		while(a == b) return 1;
		return 0;
	}
	
	public static int ngto(int n){
		if(n<2)
			return 0;
		for(int i=2; i<=Math.sqrt(n); i++)
			if(n%i==0) 
				return 0;
		return 1;
	}
	
	public static int Fibonaci(int n){
		if(n == 1 || n == 0) return 1;
		else
			return Fibonaci(n-1) + Fibonaci(n-2);
	}
	
	public static int kt_Fibo(int n){		// n la so can kiem tra
		int S=0;
		while(n>0){
			S+=n%10;
			n/=10;
		}
		for(int i=1; i<=9; i++)
			if(S == Fibonaci(i)) 
				return 1;
		return 0;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=10000; i<=9999999; i++)
			if(thuan_nghich(i) ==1 && ngto(i) ==1 && kt_Fibo(i) == 1)
				System.out.println(i);

	}

}